package com.example.test;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.test.teacher.TeacherActivity;
import com.example.test.utils.MyApplication;

public class LoginActivity extends AppCompatActivity {
    private Button loginbutton;
    private Button ykbutton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loginlayout);
        init();
        loginbutton.setOnClickListener(new MyOnClickListener());
        ykbutton.setOnClickListener(new MyOnClickListener());
    }

    private void get()
    {
        Intent intent=new Intent(LoginActivity.this,studentLoginActivity.class);
        Bundle bundle=new Bundle();
        bundle.putBoolean("status",false); // 学生
        MyApplication.setGlobalvariable("student");
        intent.putExtras(bundle);
        startActivity(intent);
    }

    private void getyk()
    {
        Intent intent=new Intent(LoginActivity.this, studentLoginActivity.class);
        Bundle bundle=new Bundle();
        bundle.putBoolean("status",true); // 教师
        MyApplication.setGlobalvariable("teacher");
        intent.putExtras(bundle);
        startActivity(intent);
    }

    class MyOnClickListener  implements View.OnClickListener
    {

        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.login_button: get();
                    break;
                case R.id.ykbutton: getyk();
                    break;
            }
        }
    }

    private void init()
    {
        loginbutton = findViewById(R.id.login_button);
        ykbutton = findViewById(R.id.ykbutton);

    }
}